﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AllegroWebAPI
{
    public class BlackList : BaseAllegroExt
    {
        public BlackList(AllegroClient a)
            : base(a)
        { 

        }

        public void Add(int userId, string note)
        {
            List<UserBlackListStruct> a = new List<UserBlackListStruct>();
            a.Add(new UserBlackListStruct() { userId = userId, userBlackListNote = note });
            var r = Add(a).ToList();
            if (r[0].addToBlackListResult != 1)
                throw new Exception(r[0].addToBlackListErrMsg);

        }

        public IEnumerable<UserBlackListAddResultStruct> Add(List<UserBlackListStruct> users)
        {
            return aapi.WebService.doAddToBlackList(aapi.SessionHandle, users.ToArray());
        }

        public IEnumerable<BlackListStruct> Get()
        {
            return aapi.WebService.doGetBlackListUsers(aapi.SessionHandle);
        }


        public void Remove(int userId)
        {
            List<long> usrs = new List<long>();
            usrs.Add(userId);
            aapi.WebService.doRemoveFromBlackList(aapi.SessionHandle, usrs.ToArray());
        }
    }
}
